package com.boatAnchorAssistant.service.repository.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.boatAnchorAssistant.pojo.entity.UserCollect;
import com.boatAnchorAssistant.service.mapper.UserCollectMapper;
import com.boatAnchorAssistant.service.repository.in.UserCollectRepository;
import nirvana.core.repository.Repository;
import org.springframework.stereotype.Service;
    import com.boatAnchorAssistant.pojo.dto.userCollect.*;
    import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 【描 述】：
* 【环 境】：J2SE
* 【详 细】：
*
*/
@Service
public class UserCollectRepositoryImpl extends Repository< UserCollectMapper , UserCollect> implements UserCollectRepository {

private final UserCollectMapper mapper;

public UserCollectRepositoryImpl(UserCollectMapper mapper) {
this.mapper = mapper;
}

    /**
    * 搜索我的收藏
    * @param dto
    * @return
    */
    @Override
    public Page< UserCollect > selectUserCollect(SelectUserCollectDto dto){

    return mapper.selectUserCollect(dto);
    }

@Override
public  Map<Long, UserCollect> getMap(List<Long> ids){
    Map<Long, UserCollect> map = new HashMap<>();

    if (CollectionUtil.isNotEmpty(ids)) {
    List<UserCollect> list =listByIds(ids);
    if (CollectionUtil.isNotEmpty(list)) {
    map = list.stream().collect(Collectors.toMap(UserCollect::getId, pojo -> pojo));
    }
    }
    return map;
    }
}